<%@page import="com.situ.student.entity.Student"%>
<%@page import="java.util.List"%>
<%@page import="com.situ.student.service.impl.StudentServiceImpl"%>
<%@page import="com.situ.student.service.IStudentService"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="lib/bootstrap-3.3.7-dist/css/bootstrap.css"/>
</head>
<body>
	 <!-- JSP脚本 -->
	<%
		String name = "zhangsan";
		IStudentService service = new StudentServiceImpl();
		List<Student> list = service.list();
	%>
	<!-- JSP表达式 :在Html页面上输出-->
	<%=name %>
	
	<%
		for (int i = 1; i <= 6; i++) {
	%>
			<h<%=i%>>标题<%=i%></h<%=i%>>
	<%
		}
	%>
	
	<%
		List<Student> list = (List<Student>)request.getAttribute("list");
	%>
	<a href="student_add.jsp">添加</a>
	<%=request.getContextPath()%> <!-- /Java1807Web -->
	<form action="<%=request.getContextPath()%>/student?method=list" method="post">
		姓名：<input type="text" name="name"/>
		<input type="submit" value="搜索"/>
	</form>
	
	<!-- 遍历List<Student> list -->
	<table class="table table-striped table-bordered table-hover table-condensed">
		<tr>
			<td><input type="checkbox"/></td>
			<td>ID</td>
			<td>姓名</td>
			<td>年龄</td>
			<td>性别</td>
			<td>修改</td>
			<td>删除</td>
		</tr>
		<%
		for (Student student : list) {
		%>
			<tr>
				<td><input type="checkbox"/></td>
				<td><%=student.getId()%></td>
				<td><%=student.getName()%></td>
				<td><%=student.getAge()%></td>
				<td><%=student.getGender()%></td>
				<td><a href="<%=request.getContextPath()%>/student?method=toUpdate&id=<%=student.getId()%>">修改</a></td>
				<td><a href="javascript:deleteById(<%=student.getId()%>)">删除</a></td>
			</tr>
		<%
		}
		%>
	</table>
	<nav aria-label="Page navigation">
	  <ul class="pagination">
	    <li>
	      <a href="#" aria-label="Previous">
	        <span aria-hidden="true">&laquo;</span>
	      </a>
	    </li>
	    <li><a href="#">1</a></li>
	    <li><a href="#">2</a></li>
	    <li><a href="#">3</a></li>
	    <li><a href="#">4</a></li>
	    <li><a href="#">5</a></li>
	    <li>
	      <a href="#" aria-label="Next">
	        <span aria-hidden="true">&raquo;</span>
	      </a>
	    </li>
	  </ul>
	</nav>
	<!--bootstrap.js用到了jquery，所以要首先引入jquery -->
	<script type="text/javascript" src="lib/jquery/jquery-1.11.1.js" ></script>
	<script type="text/javascript" src="lib/bootstrap-3.3.7-dist/js/bootstrap.js" ></script>
	<script type="text/javascript">
		function deleteById(id) {
			//用户点了确定，confirm返回的是true，
			//用户点了取消，confirm返回的是false，
			var isDel = confirm("您确认要删除么？");
			if (isDel) {
				location.href = "<%=request.getContextPath()%>/student?method=deleteById&id=" + id;
			} 
		}
	</script>
</body>
</html>